package top.laoshuzi.designpatterns.base.behavior.interpreter;

import org.junit.Test;

public class Client {

    @Test
    public void operation() {

        Variable x = new Variable("x");
        Variable y = new Variable("y");
        Constant t = new Constant(true);

        Context context = new Context();
        context.assign(x, true);
        context.assign(y, false);

        Expression expression = new And(new Or(x, y), t);
        System.out.println(expression.toString() + " = " + expression.interpret(context));
    }
}
